package or.exa.cangguan.common;

import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class Redis {

     @Autowired
     private RedisTemplate<String,Object> redisTemplate;


     private Integer timeOUt = 5;
     private Integer timeOUt2 = 7;

     public Boolean idExists(String key){
         return redisTemplate.hasKey(key);
     }

     public void set(String key,Object value){
         redisTemplate.opsForValue().set(key,value);
     }

     public void setExpire(String key,Object value){
            redisTemplate.opsForValue().set(key,value,timeOUt, TimeUnit.MINUTES);
        }
    public void setExpire2(String key,Object value){
        redisTemplate.opsForValue().set(key,value,timeOUt2, TimeUnit.DAYS);
    }

     public Object get(String key){
         return redisTemplate.opsForValue().get(key);
     }
     public void del(String key){
         redisTemplate.delete(key);
     }



}
